package com.guxingke.gsb.ui.cli;

import com.guxingke.gsb.Gsb;
import com.guxingke.gsb.util.PathUtil;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import org.kohsuke.args4j.ParserProperties;
import org.kohsuke.args4j.spi.BooleanOptionHandler;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

/**
 * 生成静态站点
 *
 * @author guxingke admin@guxingke.com
 */
public class PublishCommand implements GsbCommand {
    @Option(name = "--help", aliases = {"-h"}, handler = BooleanOptionHandler.class, usage = "find help about this command")
    private boolean help = false;

    /**
     * Executes the command
     */
    @Override
    public void execute() {
        if (help) {
            System.out.println("Publish the content in the current Griffin directory.");
            System.out.println("usage: griffin publish [option]");
            System.out.println("Options: " + PathUtil.LINE_SEPARATOR);
            CmdLineParser parser = new CmdLineParser(this, ParserProperties.defaults().withUsageWidth(120));
            parser.printUsage(System.out);
            return;
        }
        Gsb gsb = Gsb.getInstance();
        gsb.publish();
        System.out.println("All done for now! I will be bach!");
    }
}
